package com.chat.biz.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chat.api.dto.AuthFriendRelationPageDTO;
import com.chat.api.dto.AuthSetGroupDTO;
import com.chat.api.vo.AuthFriendRelationPageVO;
import com.chat.biz.service.FriendRelationService;
import com.chat.common.page.PageParam;
import com.chat.common.result.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 朋友关系控制器
 *
 * @author chenhao
 * @date 2025/06/09
 *//*
*功能：
 作者：chenhao
*日期： 2025/6/7 下午7:39
*/
@RestController
@RequestMapping("/friendrelation")
public class FriendRelationController {
    @Autowired
    private FriendRelationService friendRelationService;

    /**
     * 好友关系页面
     *
     * @param page 页
     * @param dto 到
     * @return {@link R }<{@link Page }<{@link AuthFriendRelationPageVO }>>
     */
    @GetMapping("page")
    public R<Page<AuthFriendRelationPageVO>> FriendRelationPage(@PageParam Page page, AuthFriendRelationPageDTO dto){
        return R.ok(friendRelationService.FriendRelationPage(page,dto));
    }


    /**
     * 删去
     *
     * @param friendRelationId 好友关系id
     * @return {@link R }<{@link Void }>
     */
    @DeleteMapping("delete")
    public R<Void> delete(@RequestParam("friendRelationId")  String friendRelationId){
        friendRelationService.removeById(friendRelationId);
        return R.ok();
    }

    /**
     * 设置好友分组
     *
     * @param dto 到
     * @return {@link R }<{@link Void }>
     */
    @PostMapping("setgroup")
    public R<Void> setgroup(@RequestBody @Validated AuthSetGroupDTO dto){
        friendRelationService.setgroup(dto);
        return R.ok();
    }

}
